function promiseAll(promises){
    return new Promise((resolve, reject) => {
        if(Array.isArray(promises)){
            const result = [];
            let count = 0;
            if(promises.length === 0){
                return resolve(promises)
            }
            promises.forEach((promise,index)=> {
                Promise.resolve(promise).then(
                    value => {
                        count ++
                        result[index] = value
                        count === promises.length && resolve(result);
                    },
                    reason => {
                        reject(reason)
                    }
                )
            });
        } else {
            return reject(new TypeError('Argument is not iterable'))
        }
    })
}